<?php
/**
 * Created by PhpStorm.
 * User: denson
 * Date: 16-5-31
 * Time: 下午3:25
 */

class Silk_Pms_Block_Adminhtml_Activity_Edit_Tab_Template extends Mage_Adminhtml_Block_Widget_Form
{
    public function getFormdata()
    {
        if(Mage::registry("activity_data")){
            $formdata = Mage::registry("activity_data")->getData();
            return $formdata;
        }
    }

    /**
     * 根据sku获取商品信息
     * @param $sku
     * @param $websiteId
     * @return mixed
     * @throws Mage_Core_Exception
     */
    public function getproductBysku($sku,$websiteId)
    {
        $productId = Mage::getModel('catalog/product')->getIdBySku($sku);
        $collection = Mage::getModel("catalog/product")->getCollection();
        $collection->addattributetofilter("entity_id",$productId)
            ->addAttributeToSelect('*')
            ->addWebsiteFilter($websiteId);
        $iDefaultStoreId = Mage::app()->getWebsite($websiteId)->getDefaultGroup()->getDefaultStoreId();

        $collection->joinAttribute(
            'storename',
            'catalog_product/name',
            'entity_id',
            null,
            'inner',
            $iDefaultStoreId
        );

        return $collection->getData();
    }

    /**
     * 返回网站的url
     * @return string
     */
    public function baseUrl()
    {
        return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
    }

}